import request from "/@/utils/request"
import { listByIds} from '/@/api/environment/substation'

export function fetchList(query?: Object) {
  let result= request({
    url: '/environment/equipment/page',
    method: 'get',
    params: query
  }).then(response => { 
    if(response.code===0){
      
      // const ids =response.data.records.map(obj=>obj.substationId);
      // response.data.records.map((item,index)=>{
      //     //item['substationId']= 'good'
      //     return item;
      //   })
      // let substation=null;
      // const res1=listByIds(ids).then(response=>{
      //   substation=response;
      //   return response;
      // });
      // console.log("listByIdss:"+res1)
      // console.log("response.ids:"+ids)
    }
   
    return  response;
  }) ;
  return  result
}

export function addObj(obj?: Object) {
  return request({
    url: '/environment/equipment',
    method: 'post',
    data: obj
  })
}

export function getObj(id?: string) {
  return request({
    url: '/environment/equipment/' + id,
    method: 'get'
  })
}

export function delObjs(ids?: Object) {
  return request({
    url: '/environment/equipment',
    method: 'delete',
    data: ids
  })
}

export function putObj(obj?: Object) {
  return request({
    url: '/environment/equipment',
    method: 'put',
    data: obj
  })
}

